package com.example.myapplication1.dinybehaivor.behavior;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.coordinatorlayout.widget.CoordinatorLayout;

import com.example.myapplication1.R;


/**
 * Copyright (C), 2020, 重庆八进制有限公司
 *
 * @author: weng
 * @last-modifier: weng
 * @version: 1.0
 * @create-date: 2020/12/12 15:18
 * @last-modify-date: 2020/12/12 15:18
 * @description:
 */
public class NestedScrollViewBehavior extends CoordinatorLayout.Behavior {


    public NestedScrollViewBehavior() {
    }

    public NestedScrollViewBehavior(Context context, AttributeSet attrs) {
        super(context, attrs);

    }

    @Override
    public boolean layoutDependsOn(@NonNull CoordinatorLayout parent, @NonNull View child, @NonNull View dependency) {

        return dependency.getId() == R.id.root;
    }

    @Override
    public boolean onDependentViewChanged(@NonNull CoordinatorLayout parent, @NonNull View child, @NonNull View dependency) {

        Log.e("tag","onDependentViewChanged");
        child.setTranslationY(0);

        return true;
    }

}
